/******************************************************************************
* File description: OpenFileOthersFileUploadUI.cpp
* Function: 上传文件UI
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-07
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
#include "OpenFileOthersFileUploadUI.h"

/**
 * @brief 构造函数
 */
OpenFileOthersFileUploadUI::OpenFileOthersFileUploadUI()
{
    // 初始化
    this->setResizeMode(QQuickWidget::SizeRootObjectToView);
    this->setFixedSize(656, 525);
    this->setWindowModality(Qt::ApplicationModal);
    this->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
    this->setWindowTitle("上传文件");
    this->_rootContext = this->getContext();
    // 传入OpenFileOthersFileUploadUI类
    this->rootContext()->setContextProperty("othersFileUpload", this);
    // 资源加载
    this->setSource(QUrl("qrc:/OpenFileOthersFileUpLoad.qml"));
    this->_rootObj = this->getRootObject();
    if(_rootObj){
        // 发送设备类型
        connect(_rootObj, SIGNAL(sendDeviceType(QString)), this, SIGNAL(sendDeviceType(QString)));
        // 选择文件
        connect(_rootObj, SIGNAL(selectFile()), this, SIGNAL(selectFile()));
        // 取消
        connect(_rootObj, SIGNAL(submit(QString, QString)), this, SLOT(onSubmit(QString, QString)));
        // 确认
        connect(_rootObj, SIGNAL(cancel()), this, SLOT(onCancel()));

    }
}

/**
 * @brief 析构函数
 */
OpenFileOthersFileUploadUI::~OpenFileOthersFileUploadUI()
{}

/**
 * @brief getContext 获取qmlcontext
 * @return qmlContext
 */
QQmlContext* OpenFileOthersFileUploadUI::getContext() const
{
    return this->rootContext();
}

/**
 * @brief getRootObject 获取rootObject
 * @return rootObject
 */
QObject* OpenFileOthersFileUploadUI::getRootObject() const
{
    return (QObject*)this->rootObject();
}

/**
 * @brief 获取文件路径
 * @param filePath 文件路径
 */
void OpenFileOthersFileUploadUI::filePath(QString filePath)
{
    emit OpenFileOthersFileUploadUI::sendFilePath(filePath); // 发送文件路径
}

/**
 * @brief onCancel 取消槽函数
 */
void OpenFileOthersFileUploadUI::onCancel()
{
    this->close();
}

/**
 * @brief onSubmit 确认槽函数
 */
void OpenFileOthersFileUploadUI::onSubmit(QString uploadTableData, QString analyDevice)
{
    // 发送确认信号
    // emit OpenFileOthersFileUploadUI::submit(uploadTableData, analyDevice);
}
